package com.dsmbase.corp.common;

import java.sql.Timestamp;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import com.dsmbase.corp.project.domain.ProjectFlowNode;


public class DmsUtil {
	
	public static int getCurrentMonth() {
		Calendar calendar = Calendar.getInstance();
		calendar.setTimeInMillis(System.currentTimeMillis());
		return calendar.get(Calendar.YEAR) * 100 + calendar.get(Calendar.MONTH) + 1;
	}
	
	public enum ProjectStatus {
		NOT_START,
		START,
		PROXY,
		FINISH
	}
	
	public static final int WEIGHT_FACTOR = 100;
	
	public enum ProxyIndicator {
		NON_PROXY,
		PROXY
	}
	
	/**
	 * 
	 * @param all (should be sorted by weight)
	 * @param current
	 * @return
	 */
	public static ProjectFlowNode getNextProjectNode(List<ProjectFlowNode> all, ProjectFlowNode current) {
		int targetNext = 0;
		for (int i = 0; i < all.size(); i++) {
			if (all.get(i).getId() == current.getId()) {
				targetNext = i + 1;
				break;
			}
		}
		if (targetNext <= all.size() - 1) {
			return all.get(targetNext);
		}
		return null;
	}
	
	public static Timestamp getCurrentTimestamp() {
		return new Timestamp(new Date().getTime());
	}

}
